<template>
	<view class="content">
		<view class="item">
			<view class="item-left">网格员</view>
			<view class="item-right">{{ data.checking.userName }}</view>
		</view>
		<view class="item">
			<view class="item-left">联系电话</view>
			<view class="item-right">{{ data.checking.userPhone }}</view>
		</view>
		<view class="item">
			<view class="item-left">打卡时间</view>
			<view class="item-right">{{ data.checking.checkingDate }}</view>
		</view>
		<view class="item">
			<view class="item-left">打卡类型</view>
			<view class="item-right">{{ type }}</view>
		</view>
		<view class="item">
			<view class="item-left">打卡状态</view>
			<view class="item-right">{{ status }}</view>
		</view>
		<view class="item">
			<view class="item-left">打卡网格</view>
			<view class="item-right">{{ data.checking.gridName }}</view>
		</view>
		<view class="item">
			<view class="item-left">打卡地点</view>
			<view class="item-right">{{ data.checking.address || '暂无资料' }}</view>
		</view>
		<view class="item">
			<view class="item-left">是否在网格内</view>
			<view class="item-right">是</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				checkingId:'',
				data:{
					checking:{}
				},
				dictList:[],
				dictList1:[],
				status:'',
				type:''
			}
		},
		onLoad(options) {
			this.checkingId = options.id
		},
		mounted() {
			this.getCheckingDetail()
			this.getDictionaries()
			this.getDictionaries2()
		},
		methods:{
			// 打卡状态字典
			getDictionaries() {
				let params = {
					dictCode:'checking_status_dict'
				}
				this.$u.api.dictionaries(params)
					.then(res => {
						if(res.code == 200) {
							res.result.forEach(item => {
								this.dictList.push({
									value:item.value,
									label:item.text
								})
							})
						}
					})
					.catch(err => {
						console.log(err)
					})
			},
			// 打卡类型字典
			getDictionaries2() {
				let params = {
					dictCode:'checking_type_dict'
				}
				this.$u.api.dictionaries(params)
					.then(res => {
						if(res.code == 200) {
							res.result.forEach(item => {
								this.dictList1.push({
									value:item.value,
									label:item.text
								})
							})
						}
					})
					.catch(err => {
						console.log(err)
					})
			},
			
			getCheckingDetail() {
				let params = {
					checkingId:this.checkingId
				}
				this.$u.api.getCheckingDetail(params)
					.then(res => {
						// console.log(res)
						if(res.code == 200) {
							this.data = res.result
							this.dictList.forEach(item => {
								if(item.value == res.result.checking.checkingStatus) {
									this.status = item.label
								}
							})
							this.dictList1.forEach(item => {
								if(item.value == res.result.checking.checkingType) {
									this.type = item.label
								}
							})
						}
					})
					.catch(err => {
						console.log(err)
					})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding: 20rpx;
		background-color: #fff;
		min-height: 100vh;
		.item{
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 0;
			border-bottom: 1px solid #f4f1f1;
			.item-left{
				color: #333;
				font-size: 27rpx;
			}
			.item-right{
				color: #888;
				font-size: 27rpx;
			}
		}
	}
</style>
